//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.zhonghui.license;

import de.schlichtherle.license.CipherParam;
import de.schlichtherle.license.DefaultCipherParam;
import de.schlichtherle.license.DefaultLicenseParam;
import de.schlichtherle.license.KeyStoreParam;
import de.schlichtherle.license.LicenseContent;
import de.schlichtherle.license.LicenseManager;
import de.schlichtherle.license.LicenseParam;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.prefs.Preferences;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class LicenseVerify {
    private static Logger logger = LogManager.getLogger(LicenseVerify.class);

    public LicenseVerify() {
    }

    public synchronized LicenseContent install(LicenseVerifyParam param) {
        LicenseContent result = null;
//        new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//
//        try {
//            LicenseManager licenseManager = LicenseManagerHolder.getInstance(this.initLicenseParam(param));
//            licenseManager.uninstall();
//            if (StringUtils.isBlank(param.getLicensePath())) {
//                param.setLicensePath(System.getProperty("user.dir"));
//            }
//
//            File licensePath = new File(param.getLicensePath());
//            File[] files = licensePath.listFiles(new FRFilenameFilter());
//            if (files.length == 0) {
//                throw new Exception("没有证书文件");
//            }
//
//            File licenseFile = files[0];
//            result = licenseManager.install(licenseFile);
//        } catch (Exception var8) {
//            logger.error("证书安装失败！", var8);
//        }

        return result;
    }

    public boolean verify() {
        return true;
//        LicenseManager licenseManager = LicenseManagerHolder.getInstance((LicenseParam)null);
//        new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//
//        try {
//            LicenseContent licenseContent = licenseManager.verify();
//            return true;
//        } catch (Exception var4) {
//            logger.error("证书校验失败！", var4);
//            return false;
//        }
    }

    private LicenseParam initLicenseParam(LicenseVerifyParam param) {
        Preferences preferences = Preferences.userNodeForPackage(LicenseVerify.class);
        CipherParam cipherParam = new DefaultCipherParam(param.getStorePass());
        KeyStoreParam publicStoreParam = new CustomKeyStoreParam(LicenseVerify.class, param.getPublicKeysStorePath(), param.getPublicAlias(), param.getStorePass(), (String)null);
        return new DefaultLicenseParam(param.getSubject(), preferences, publicStoreParam, cipherParam);
    }
}
